package com.fulihui.weixinclient.model;

import org.apache.commons.lang3.StringUtils;
import org.near.toolkit.model.ToString;

public class QRCodeTicket extends ToString {
    private static final long  serialVersionUID           = -6282934636000451964L;

    public static final String ACTION_NAME_QR_SCENE       = "QR_SCENE";           //临时
    public static final String ACTION_NAME_QR_LIMIT_SCENE = "QR_LIMIT_SCENE";     //永久

    private int                expire_seconds;

    private String             action_name;

    private int                scene_id;

    public String toJSON() {
        if (StringUtils.isNotEmpty(action_name)) {
            StringBuffer jsonBuffer = new StringBuffer();
            //{"expire_seconds": 604800, "action_name": "QR_SCENE", "action_info": {"scene": {"scene_id": 123}}}
            jsonBuffer.append("{");
            if (action_name.equals(ACTION_NAME_QR_SCENE)) {
                jsonBuffer.append("\"expire_seconds\":").append(expire_seconds).append(",");
            }
            jsonBuffer.append("\"action_name\":\"").append(action_name).append("\",");
            jsonBuffer.append("\"action_info\":").append("{\"scene\":").append("{\"scene_id\":")
                .append(scene_id).append("}}");
            jsonBuffer.append("}");

            return jsonBuffer.toString();
        }
        return "";
    }

    public int getExpire_seconds() {
        return expire_seconds;
    }

    public void setExpire_seconds(int expire_seconds) {
        this.expire_seconds = expire_seconds;
    }

    public String getAction_name() {
        return action_name;
    }

    public void setAction_name(String action_name) {
        this.action_name = action_name;
    }

    public int getScene_id() {
        return scene_id;
    }

    public void setScene_id(int scene_id) {
        this.scene_id = scene_id;
    }
}